<template>
    <el-card shadow="never" header="个人信息">
        <el-form
            ref="dialogForm"
            :rules="rules"
            :model="entityObj"
            label-width="120px"
            style="margin-top: 20px"
        >
            <!-- <el-form-item label="机构编码">
                <el-input v-model="entityObj.OrgCode" disabled></el-input>
            </el-form-item>
            <el-form-item label="机构名称">
                <el-input v-model="entityObj.OrgName" disabled></el-input>
            </el-form-item> -->
            <el-form-item label="账号">
                <el-input v-model="entityObj.Code" disabled></el-input>
                <div class="el-form-item-msg">账号信息用于登录，系统不允许修改</div>
            </el-form-item>
            <el-form-item label="姓名">
                <el-input v-model="entityObj.Name"></el-input>
            </el-form-item>
            <!-- <el-form-item label="性别">
				<el-select v-model="entityObj.SexCode" placeholder="请选择">
					<el-option label="保密" value=""></el-option>
					<el-option label="男" value="011001"></el-option>
					<el-option label="女" value="011002"></el-option>
				</el-select>
            </el-form-item>-->
            <el-form-item label="手机">
                <el-input v-model="entityObj.Mobile"></el-input>
            </el-form-item>
            <!-- <el-form-item label="微信">
				<el-input v-model="entityObj.WeChat"></el-input>
            </el-form-item>-->
            <!-- <el-form-item label="个性签名">
				<el-input v-model="entityObj.Remark" type="textarea"></el-input>
			</el-form-item>
			-->
			<el-form-item>
				<el-button type="primary" @click="submit" :disabled="isSaveing">保存</el-button>
            </el-form-item>
        </el-form>
    </el-card>
</template>

<script>
import publicjs from "@/api/model/publicjs";
import tool from "@/utils/tool";
import bus from "@/utils/mitt";
export default {
    data() {
        return {
            mode: "edit",
            userCode: "",
            entityObj: {
                OrgCode: "管理员",
                OrgName: "管理员",
                Code: "administrator@scuiadmin.com",
                Name: "Sakuya",
                Mobile: "13888888888",
            },
            rules: {
                Name: [{ required: true, type: "string", message: "请填写" }],
                Mobile: [{ required: true, type: "string", message: "请填写" }],
                WeChat: [{ required: true, type: "string", message: "请填写" }],
            },
            saveState: false,
			isSaveing:false,
        };
    },
    methods: {
        //表单提交方法
        submit() {
            this.$refs.dialogForm.validate(async (valid) => {
                // eslint-disable-next-line no-debugger
                //debugger;
                if (valid) {
					this.isSaveing=true;
                    var returnValue = await this.$API.auth.PostProcessApi.post(
                        "account/update-current",
                        {
                            realName: this.entityObj.Name,
                            mobile: this.entityObj.Mobile,
                        }
                    );
                    if (returnValue.status == 200) {
                        this.$message.success("操作成功");
                        this.isSaveing = false;
                    } else {
                        this.$message.error("操作失败:" + returnValue.msg);
                        this.isSaveing = false;
                    }
                }
            });
        },

        //表单注入数据
        async setData() {
            try {
                var returnValue = await this.$API.auth.PostProcessApi.post(
                    "account/current-user",
                    {}
                );
                if (returnValue.status == 200) {
                    const response = returnValue.response;
                    this.entityObj.OrgCode = response.orgCode;
                    this.entityObj.OrgName = response.orgName;
                    this.entityObj.Code = response.accountCode;
                    this.entityObj.Name = response.realName;
                    this.entityObj.Mobile = response.mobile;
                }
            } catch (error) {
                return false;
            }
        },
    },
    async mounted() {
        await this.setData();
    },
};
</script>

<style></style>
